import requests


class HmshopLoginApi(object):
    base_url = "http://hmshop-test.itheima.net/index.php"

    @classmethod
    def get_verifyCode(cls, session):
        session.get(url=cls.base_url, params={"m": "Home", "c": "User", "a": "verify"})

    @classmethod
    def login(cls, session, data):
        response = session.post(url=cls.base_url, params={"m": "Home", "c": "User", "a": "do_login"},
                                data=data)
        return response


if __name__ == '__main__':
    session = requests.session()
    HmshopLoginApi.get_verifyCode(session)
    result = HmshopLoginApi.login(session, {"username": "13800000002", "password": "123456", "verify_code": "8888"})
    print("登录结果：", result.json())
